package lang

import (
	"gvm/native/basic"
	"gvm/rtda"
	"gvm/rtda/heap"
)

func RegisterString() (className string, methods []*basic.NaMethod) {
	return "java/lang/String", []*basic.NaMethod{
		{
			"intern",
			"()Ljava/lang/String;",
			intern,
		},
	}
}

// public native String intern();
func intern(jFrame *rtda.JFrame) {
	this := jFrame.LocalVars().GetThis()
	interned := heap.InterString(this)
	jFrame.OperandStack().PushRef(interned)
}
